package com.yiren.manager.service.impl.lease;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yiren.core.exception.MyException;
import com.yiren.core.service.GenericServiceImpl;
import com.yiren.core.utils.Favorites;
import com.yiren.entity.YrLeaseSupply;
import com.yiren.entity.YrRetreatLease;
import com.yiren.manager.repository.lease.YrRetreatLeaseRepository;
import com.yiren.manager.repository.pension.YrLeaseSupplyRepository;
import com.yiren.manager.service.iface.lease.YrRetreatLeaseService;

@Service
public class YrRetreatLeaseServiceImpl extends GenericServiceImpl<YrRetreatLease, String> implements YrRetreatLeaseService{

	@Autowired
	private YrLeaseSupplyRepository leaseSupplyRepository;
	
	@Autowired
	public YrRetreatLeaseServiceImpl(YrRetreatLeaseRepository repository) {
		super(repository);
	}

	public void addByFavorites(Favorites entitys) throws MyException {
		YrLeaseSupply supply = entitys.getFavorite(YrLeaseSupply.class);
		YrRetreatLease retreatLease = entitys.getFavorite(YrRetreatLease.class);
		
		this.repository.save(retreatLease);
		leaseSupplyRepository.save(supply);
	}

}
